vtag=function(){
    console.log(arguments);
    if(arguments.length==2){
        return {tag:arguments[0],attrs:{},children:arguments[1]}
    }
    return {tag:arguments[0],attrs:arguments[1],children:arguments[2]}
}

var render=function(dom,vnode){
    dom.innerHTML="";
    renderHandler(dom,vnode);
}
var renderHandler=function(dom,vnode){
    if(Array.isArray(vnode)){
        for(var i=0;i<vnode.length;i++){
            //递归
            renderHandler(dom,vnode[i]);
        }
        return dom;
    }
    var truthTag=document.createElement(vnode.tag);
    for(var key in vnode.attrs){
        truthTag.setAttribute(key,vnode.attrs[key]);
    }
    if(typeof vnode.children=="string"){
        truthTag.innerText=vnode.children;
        dom.appendChild(truthTag);
        return dom;
    }
    else if(typeof vnode.children=="object"){
        dom.appendChild(truthTag);
        renderHandler(truthTag,vnode.children);
        return dom
    }
}

m=function(){
    return vtag.apply(this,arguments);
}
m.render=render;

if (typeof module !== "undefined")
    module["exports"] = m
else 
    window.m = m